package jcoyote;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * A server class is a representation of Q3 based game server
 * consisting of a name, ip, port, login method, and password.
 * 
 * @author Pyrite[1up]
 */

public class Server implements Serializable {

    /** The server name. */
    private String name;
    
    /** The server IPv4 address. */
    private String ip;

    /** The server port (usually 27960). */
    private String port;
    
    /** The password to remote control */
    private String rcon;

    public Server() {
        this.name = "";
        this.ip = "";
        this.port = "27960";
        this.rcon = "" ;
    }

    /**
     * Constructs a server object given the following parameters:
     *
     * @param name The server name.
     * @param ip The server IPv4 address.
     * @param port The server port, usually just 27960.
     * 
     */
    public Server(String name, String ip, String port, String rcon) {
        this.name = name;
        this.ip = ip;
        this.port = port;
        this.rcon = rcon ;
    }

    public String getName() {
        return this.name;
    }

    public String getIP() {
        return this.ip;
    }

    public String getPortAsString() {
        return this.port;
    }

    public int getPortAsInteger() {
        return Integer.parseInt(this.port);
    }
    
    public String[] toArray() {
        String[] server = {this.name, this.ip, this.port };
        return server;
    }
    
    public String getRcon() {
        return this.rcon;
    }
    
    @Override public String toString() {
        return this.name;
    }

}